//
//  DownChildOneView.m
//  FoodCorner
//
//  Created by lanou3g on 16/2/27.
//  Copyright © 2016年 zhangchao. All rights reserved.
//

#import "DownChildOneView.h"
#define Wself self.frame.size.width
#define Hself self.frame.size.height

@interface DownChildOneView ()



@end

@implementation DownChildOneView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self andSubView];
    }
    return self;
}
- (void)andSubView{
    
  
    self.buttonOne = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [self.buttonOne setTitle:@"作品" forState:UIControlStateNormal];
    
    [self.buttonOne setTitleColor:[UIColor redColor] forState:UIControlStateNormal];

    
    
    [self.buttonOne addTarget:self action:@selector(buttonOneAction:) forControlEvents:UIControlEventTouchUpInside];
    
//    self.buttonOne.backgroundColor = [UIColor blackColor];
   
    self.buttonTwo = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [self.buttonTwo setTitle:@"菜谱" forState:UIControlStateNormal];
//        self.buttonTwo.backgroundColor = [UIColor blackColor];
    
      [self.buttonTwo addTarget:self action:@selector(buttonTwoAction:) forControlEvents:UIControlEventTouchUpInside];
 
      [self.buttonTwo setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    [self addSubview:_buttonOne];
    [self addSubview:_buttonTwo];
}

- (void)layoutSubviews{
    

    
     self.buttonOne.frame = CGRectMake(Hself *0.5, Hself *0.3, Hself *0.8, Hself *0.3);
     self.buttonTwo.frame = CGRectMake(CGRectGetMaxX(self.buttonOne.frame) + 2*Hself, Hself *0.3, Hself *0.8, Hself *0.3);
}

- (void)buttonOneAction:(UIButton *)button{
    
    [self.buttonOne setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    
    [self.buttonTwo setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    
    
}

- (void)buttonTwoAction:(UIButton *)button{
    
    [self.buttonOne setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    [self.buttonTwo setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    
}




@end
